--[[
    iOS
    采用逻辑分辨率
    https://blog.csdn.net/a18339063397/article/details/81482073
]]
local function LoadiPhoneScale()
  require('assets/font/FontLib') -- 设置属性
  require('assets/font/FontLevelLib') -- 设置属性
  require('assets/font/iphoneFontNum') -- 设置属性

  local ctn = 0

  -- dialog('width='..width..' height='..height, 10)
  if width == 1280 and height == 700 then
    ctn = 1    --模拟器 - 雷电模拟器
  elseif  width == 1080 and height == 1920 then --模拟器 - 木木模拟器
    ctn = 1
  -- elseif width == 320 and height == 480 then
  elseif width == 640 and height == 960 then   -- 4/4s
    ctn = 1
  -- elseif width == 320 and height == 568 then
  elseif width == 640 and height == 1136 then  -- 5/5s/5c/se
    ctn = 1
  -- elseif width == 375 and height == 667 then
  elseif width == 750 and height == 1334 then  -- 6/6s/7/8
    ctn = 1
  -- elseif width == 414 and height == 736 then
  elseif width == 1242 and height == 2208 then -- 6plus/6splus/7plus/8plus
    ctn = 1
  -- elseif width == 375 and height == 812 then
  elseif width == 1125 and height == 2436 then -- iPhoneX / Xs / 11Pro / 12mini /
    ctn = 1
  -- elseif width == 414 and height == 896 then
  elseif width == 828 and height == 1792 then  -- Xr/XsMax/11/11proMax/
    ctn = 1
  -- elseif width == 390 and height == 844 then
  elseif width == 1170 and height == 2532 then  -- iPhone12 / 12pro
    ctn = 1
  -- elseif width == 428 and height == 926 then
  elseif width == 1284 and height == 2778 then  -- iPhone12proMax
    ctn = 1
  -- elseif width == 768 and height == 1024 then
  elseif width == 1536 and height == 2048 then  --ipad9.7 / 9.7mini /ipad Pro / iPad五代 / iPad Air / iPad4
    ctn = 1
  -- elseif width == 834 and height == 1112 then
  elseif width == 1668 and height == 2224 then  --ipad10.5
    ctn = 1
  -- elseif width == 1536 and height == 2048 then
  --     ctn = 1 --iPad 3,4,5,mini 2
  --
  else
    dialog("暂不支持此设备 iPhone", 0)
    RxLog('      RxDeviceScale 暂不支持此设备 iPhone')
    ctn = 0
  end
  return ctn
end

--[[
    Android
    采用逻辑分辨率: width == 1080 and height == 1920
    Dpi: 480dpi
]]

local function LoadAndroidRes()
  -- 资源：字库
  require('assets/font/FontLib') -- 设置属性
  require('assets/font/FontLevelLib') -- 设置属性
  require('assets/font/FontNumber') -- 设置属性
end
local function LoadAndroidScale()
  LoadAndroidRes()
  local ctn = 0
  if width == 1080 and height == 1920 then
    ctn = 1    --三星n9009
  elseif width == 1280 and height == 700 then   --模拟器
    ctn = 1
  elseif width == 1280 and height == 800 then   --模拟器
    ctn = 1
  elseif width == 1664 and height == 1040 then  --模拟器
    ctn = 1
  elseif width == 1080 and height == 1920 then  -- 小米 4，华为荣耀 6p 等
    ctn = 1
  elseif width == 800 and height == 1280 then   -- 三星 N5100 等
    ctn = 1
  elseif width == 768 and height == 1280 then   -- 魅蓝等
    ctn = 1
  elseif width == 720 and height == 1280 then   -- 红米 note2 等
    ctn = 1
  elseif width == 400 and height == 800 then    -- 酷派 8017-T00 等
    ctn = 1
  else
    dialog("暂不支持此设备 Android", 0)
    RxLog('      RxDeviceScale 暂不支持此设备 Android')
    ctn = 0
  end
  return ctn
end

local function LoadSimulatorScale()
  LoadAndroidRes()
  local ctn = 0
  if width == 720 and height == 1280 then
    ctn = 1
  elseif width == 700 and height == 1280 then
    ctn = 1
  elseif  width == 1080 and height == 1920 then
    ctn = 1
  else
    dialog("暂不支持此设备 模拟器建议 700x1280", 0)
    RxLog('      RxDeviceScale 暂不支持此设备 模拟器建议 700x1280')
    ctn = 0
  end
  return ctn
end



function RxDeviceScale()
  local ctn = 0
  local types = sysInit.deviceType
  if types == 1 then
    RxToast("当前设备为 iPhone")
    ctn = LoadiPhoneScale()
  elseif types == 2 then
    RxToast("当前设备为安卓真机")
    ctn = LoadAndroidScale()
  else
    RxToast("当前设备为安卓模拟器", 5)
    ctn = LoadSimulatorScale()
  end
  return ctn
end